﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using KingRoad.EPM.SafetyManagementBLL.Domain;
using KingRoad.EPM.SafetyManagementEntity.Model;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.SafetyManagementDAL.ScmThreePersonnelService;


namespace KingRoad.EPM.SafetyManagementBLL.UIRules
{
    /// <summary> 
    /// 客户端业务处理类。 
    /// 文件生成时间 2017/3/13 14:46:26
    /// </summary> 
    public class ScmThreepersonnelUIRule
    {
        private readonly IScmThreepersonnelService _scmThreepersonnelService;
        
        
        public ScmThreepersonnelUIRule(){}
        
        /// <summary> 
        /// construct function... 
        /// </summary> 
        public ScmThreepersonnelUIRule(IScmThreepersonnelService  scmThreepersonnelService)
        {
           _scmThreepersonnelService=scmThreepersonnelService;
        }
        /// <summary>
        /// 获取三类人员台账信息
        /// </summary>
        /// <returns></returns>
        public List<ScmThreepersonnelInfo> GetAllThreePersonnelBySection(string sql)
        {
            var list = _scmThreepersonnelService.GetEntityList(sql);
            return list;
        }
        /// <summary>
        /// 根据ID获取Info
        /// </summary>
        /// <param name="parentID">主键ID</param>
        /// <returns></returns>
        public ScmThreepersonnelInfo GetInfoByID(Guid ID)
        {
            var list = _scmThreepersonnelService.GetEntityById(ID);
            return list;
        }
        /// <summary>
        /// 根据条件查询List信息(分页)
        /// </summary>
        /// <param name="numCurrentPage">当前页</param>
        /// <param name="numPerPage">每页数据大小</param>
        /// <param name="orderByField">排序字段名称</param>
        /// <param name="totalRecord">总数据量</param>
        /// <param name="sqlCondition">sql查询条件</param>
        /// <returns></returns>
        public List<ScmThreepersonnelInfo> GetListForPage(int numCurrentPage, int numPerPage,
                                                                        string orderByField, out int totalRecord, string sqlCondition, string desc = "asc")
        {
            var list = _scmThreepersonnelService.GetEntityListByContionRe(numCurrentPage, numPerPage, orderByField, out totalRecord, sqlCondition, desc);
            return list;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool InsertEntity(ScmThreepersonnelInfo entity)
        {
            var ret = _scmThreepersonnelService.InsertEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public bool UpdateEntity(ScmThreepersonnelInfo entity)
        {
            var ret = _scmThreepersonnelService.UpdateEntity(entity);
            return ret > 0;
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DeleteEntity(string id)
        {
            var ret = _scmThreepersonnelService.DeleteEntityByStringID(id);
            return ret > 0;
        }
        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public bool DeleteEntityByMultiStringID(string ids)
        {
            var ret = 0;
            foreach (string id in ids.Split(','))
            {
                ret = _scmThreepersonnelService.DeleteEntityByStringID(id);
            }
            return ret > 0;
        }
    }
}

